﻿using System;
using System.Collections.Generic;
using System.Resources;
using System.Text;
using System.IO;
using FeCMS.Entity.AccessControlModule;

namespace FeCMS.AccessControlModule
{
    /// <summary>
    ///     资源文件的操作
    /// </summary>
    internal class FeResourceManager
    {
        #region 私有变量

        private static readonly string path = "mydb.resources";

        private readonly string name = "PerEntity";

        #endregion


        #region 公有方法

        /// <summary>
        ///     添加资源
        /// </summary>
        /// <param name="name"></param>
        /// <param name="t"></param>
        public void Add(PermissionDBEntity accessControl)
        {
            using (IResourceWriter rw = new ResourceWriter(path))
            {
                rw.AddResource(name, accessControl);
                rw.Generate();
            }
        }
        /// <summary>
        ///     获取资源
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public PermissionDBEntity Get()
        {
            using (ResourceSet rs = new ResourceSet(path))
            {
                return (PermissionDBEntity)rs.GetObject(name);
            }
        }

        #endregion

    }
}
